services:
  nginx:
    restart: always
    image: nginx:{{ nginx.version }}
    volumes:
      - {{ project.dir }}/{{ project.name }}/app/:{{ project.dir }}/{{ project.name }}/app/
      - {{ project.dir }}/{{ project.name }}/{{ nginx.volumes.cert }}/:/etc/nginx/cert/
      - {{ project.dir }}/{{ project.name }}/{{ nginx.volumes.conf }}/:/etc/nginx/
      - {{ project.dir }}/{{ project.name }}/{{ nginx.volumes.logs }}/:/var/log/nginx/
    ports:
      - 80:80
      - 443:443
    links:
      - php
    depends_on:
      - php

  php:
    restart: always
    image: php:{{ php.version }}
    volumes:
      - {{ project.dir }}/{{ project.name }}/app:{{ project.dir }}/{{ project.name }}/app
      - {{ project.dir }}/{{ project.name }}/{{ php.volumes.conf }}/:/usr/local/etc/
    links:
      - mysql

  mysql:
    restart: always
    image: mysql:{{ mysql.version }}
    ports:
      - 3306:3306
    volumes:
      - {{ project.dir }}/{{ project.name }}/{{ mysql.volumes.data }}/:/var/lib/mysql/
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: yes
      MYSQL_DATABASE: {{ project.domain | replace('.', '_') }}
      MYSQL_USER: {{ project.domain | replace('.', '_') }}
      MYSQL_PASSWORD: {{ mysql.db_password }}